<!DOCTYPE html><html><head>
      <title>AES&#x52A0;&#x5BC6;&#x7B97;&#x6CD5;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      
        <script type="text/x-mathjax-config">
          MathJax.Hub.Config({"extensions":["tex2jax.js"],"jax":["input/TeX","output/HTML-CSS"],"messageStyle":"none","tex2jax":{"processEnvironments":false,"processEscapes":true,"inlineMath":[["$","$"],["\\(","\\)"]],"displayMath":[["$$","$$"],["\\[","\\]"]]},"TeX":{"extensions":["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]},"HTML-CSS":{"availableFonts":["TeX"]}});
        </script>
        <script type="text/javascript" async src="file:///c:\Users\Lenovo\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.5.13\node_modules\@shd101wyy\mume\dependencies\mathjax\MathJax.js" charset="UTF-8"></script>
        
      
      
      
      
      
      
      
      
      
      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <h1 class="mume-header" id="aes%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95toc"><a href="#toc">AES&#x52A0;&#x5BC6;&#x7B97;&#x6CD5;</a></h1>

<ul>
<li><a href="#aes%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95toc">AES&#x52A0;&#x5BC6;&#x7B97;&#x6CD5;</a>
<ul>
<li><a href="#aes%E7%AE%97%E6%B3%95%E6%B5%81%E7%A8%8Btoc">AES&#x7B97;&#x6CD5;&#x6D41;&#x7A0B;</a></li>
<li><a href="#subbytes%E5%8F%98%E6%8D%A2toc">SubBytes&#x53D8;&#x6362;</a></li>
<li><a href="#shiftrows%E5%8F%98%E6%8D%A2toc">ShiftRows&#x53D8;&#x6362;</a></li>
<li><a href="#mixcolumns%E5%8F%98%E6%8D%A2toc">MixColumns&#x53D8;&#x6362;</a></li>
<li><a href="#addroundkey%E5%8F%98%E6%8D%A2toc">AddRoundKey&#x53D8;&#x6362;</a></li>
<li><a href="#roundkey%E8%AE%A1%E7%AE%97toc">RoundKey&#x8BA1;&#x7B97;</a></li>
<li><a href="#%E9%99%84%E5%BD%95toc">&#x9644;&#x5F55;</a>
<ul>
<li><a href="#%E9%9D%9E%E7%BA%BF%E6%80%A7%E5%AD%97%E8%8A%82%E6%9B%BF%E6%8D%A2%E8%A1%A8toc">&#x975E;&#x7EBF;&#x6027;&#x5B57;&#x8282;&#x66FF;&#x6362;&#x8868;</a></li>
</ul>
</li>
<li><a href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99toc">&#x53C2;&#x8003;&#x8D44;&#x6599;</a></li>
</ul>
</li>
</ul>
<p><span id="toc"></span></p>
<p>&#x8BB0;&#x6709;&#x5982;&#x4E0B;&#x5B9A;&#x4E49;:</p>
<ul>
<li>State: &#x5BF9;&#x660E;&#x6587;&#x52A0;&#x5BC6;&#x7684;&#x4E2D;&#x95F4;&#x72B6;&#x6001;, &#x662F;&#x4E00;&#x4E2A;<span class="mathjax-exps">$4*N_b$</span>&#x7684;&#x77E9;&#x9635;, &#x521D;&#x59CB;&#x72B6;&#x6001;&#x7B49;&#x4E8E;&#x8F93;&#x5165;;</li>
<li>CipherKey: &#x5BC6;&#x94A5;, &#x53EF;&#x4EE5;&#x770B;&#x6210;&#x4E00;&#x4E2A;<span class="mathjax-exps">$4*N_k$</span>&#x7684;&#x77E9;&#x9635;;</li>
<li><span class="mathjax-exps">$N_b$</span>: State&#x77E9;&#x9635;&#x7684;&#x5217;&#x6570;, <span class="mathjax-exps">$N_b=4$</span>;</li>
<li><span class="mathjax-exps">$N_k$</span>: &#x5BC6;&#x94A5;&#x5B57;&#x957F;(1&#x5B57;=32bits), <span class="mathjax-exps">$N_k=4,6,8$</span>;</li>
<li><span class="mathjax-exps">$N_r$</span>: &#x52A0;&#x5BC6;&#x7684;&#x8F6E;&#x6570;, <span class="mathjax-exps">$N_r=10,12,14$</span>;</li>
<li>RoundKey: &#x7531;CipherKey&#x4EA7;&#x751F;, &#x6BCF;&#x4E00;&#x8F6E;&#x52A0;&#x5BC6;&#x8BA1;&#x7B97;&#x5BF9;&#x5E94;&#x4E00;&#x4E2A;RoundKey;</li>
<li>KeyExpansion: &#x5C06;CipherKey&#x8F6C;&#x4E3A;RoundKey;</li>
<li>AddRoundKey: &#x4F7F;&#x7528;RoundKey&#x5BF9;State&#x8FDB;&#x884C;&#x52A0;&#x5BC6;&#x8BA1;&#x7B97;(RoundKey&#x548C;State&#x5F02;&#x6216;&#x64CD;&#x4F5C;);</li>
<li>SubBytes: &#x4F7F;&#x7528;&#x975E;&#x7EBF;&#x6027;&#x5B57;&#x8282;&#x66FF;&#x6362;&#x8868;sbox&#x5BF9;State&#x8FDB;&#x884C;&#x66FF;&#x6362;&#x64CD;&#x4F5C;;</li>
<li>ShiftRows: &#x5BF9;State&#x77E9;&#x9635;&#x540E;&#x4E09;&#x884C;&#x8FDB;&#x884C;&#x504F;&#x79FB;&#x64CD;&#x4F5C;;</li>
<li>MixColumns: &#x5BF9;State&#x77E9;&#x9635;&#x7684;&#x6240;&#x6709;&#x5217;&#x8FDB;&#x884C;&#x5217;&#x6DF7;&#x5408;&#x64CD;&#x4F5C;;</li>
</ul>
<p>&#x5BC6;&#x94A5;&#x957F;&#x5EA6;&#x548C;<span class="mathjax-exps">$N_b, N_k, N_r$</span>&#x5BF9;&#x5E94;&#x5173;&#x7CFB;&#x5982;&#x4E0B;&#x8868;:</p>
<table>
<thead>
<tr>
<th style="text-align:center"></th>
<th style="text-align:center"><span class="mathjax-exps">$N_k$</span></th>
<th style="text-align:center"><span class="mathjax-exps">$N_b$</span></th>
<th style="text-align:center"><span class="mathjax-exps">$N_r$</span></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">AES-128</td>
<td style="text-align:center">4</td>
<td style="text-align:center">4</td>
<td style="text-align:center">10</td>
</tr>
<tr>
<td style="text-align:center">AES-192</td>
<td style="text-align:center">6</td>
<td style="text-align:center">4</td>
<td style="text-align:center">12</td>
</tr>
<tr>
<td style="text-align:center">AES-256</td>
<td style="text-align:center">8</td>
<td style="text-align:center">4</td>
<td style="text-align:center">18</td>
</tr>
</tbody>
</table>
<h2 class="mume-header" id="aes%E7%AE%97%E6%B3%95%E6%B5%81%E7%A8%8Btoc"><a href="#toc">AES&#x7B97;&#x6CD5;&#x6D41;&#x7A0B;</a></h2>

<p>AES&#x7B97;&#x6CD5;&#x4F2A;&#x4EE3;&#x7801;&#x5982;&#x4E0B;:</p>
<pre data-role="codeBlock" data-info="matlab" class="language-matlab"><span class="token function">Cipher</span><span class="token punctuation">(</span>byte in<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> byte out<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> word w<span class="token punctuation">[</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
begin
    byte state<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> Nb<span class="token punctuation">]</span>
    state <span class="token operator">=</span> in
    <span class="token function">AddRoundkey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> Nb<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    <span class="token keyword">for</span> round <span class="token operator">=</span> <span class="token number">1</span> step <span class="token number">1</span> to Nr<span class="token operator">-</span><span class="token number">1</span>
        <span class="token function">SubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">ShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">MixColumns</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>round<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>round<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
    <span class="token keyword">end</span>

    <span class="token function">SubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">ShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>Nr<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    out <span class="token operator">=</span> state
<span class="token keyword">end</span>

<span class="token function">InvCipher</span><span class="token punctuation">(</span>byte in<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> byte out<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> word w<span class="token punctuation">[</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr_1<span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
begin

    byte stae<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> Nb<span class="token punctuation">]</span>
    state <span class="token operator">=</span> in

    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>Nr<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    <span class="token keyword">for</span> round <span class="token operator">=</span> Nr<span class="token operator">-</span><span class="token number">1</span> step <span class="token operator">-</span><span class="token number">1</span> downto <span class="token number">1</span>
        <span class="token function">InvShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">InvSubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>round<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>round<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
        <span class="token function">InvMixColumns</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token keyword">end</span>

    <span class="token function">InvShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">InvSubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> Nb<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    out <span class="token operator">=</span> state
<span class="token keyword">end</span>


<span class="token operator">/</span><span class="token operator">/</span> &#x53E6;&#x4E00;&#x79CD;&#x7B49;&#x6548;&#x7684;&#x52A0;&#x89E3;&#x5BC6;&#x6B65;&#x9AA4;<span class="token punctuation">,</span> Intel AES&#x6307;&#x4EE4;&#x96C6;&#x91C7;&#x7528;&#x7684;&#x662F;&#x8FD9;&#x79CD;&#x6B65;&#x9AA4;<span class="token punctuation">(</span>&#x4E24;&#x5219;&#x52A0;&#x5BC6;&#x5BC6;&#x94A5;&#x6269;&#x5C55;&#x662F;&#x6837;&#x7684;<span class="token punctuation">)</span>
<span class="token operator">/</span><span class="token operator">/</span> SubBytes&#x548C;ShiftRows&#x53EF;&#x4EE5;&#x4EA4;&#x6362;
<span class="token operator">/</span><span class="token operator">/</span> <span class="token function">InvMixColumns</span><span class="token punctuation">(</span><span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> RoundKey<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token function">AddRoundKey</span><span class="token punctuation">(</span><span class="token function">InvMixColumns</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">InvMixColumns</span><span class="token punctuation">(</span>RoundKey<span class="token punctuation">)</span>

<span class="token function">Cipher</span><span class="token punctuation">(</span>byte in<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> byte out<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> word w<span class="token punctuation">[</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
begin
    byte state<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> Nb<span class="token punctuation">]</span>
    state <span class="token operator">=</span> in
    <span class="token function">AddRoundkey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> Nb<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    <span class="token keyword">for</span> round <span class="token operator">=</span> <span class="token number">1</span> step <span class="token number">1</span> to Nr<span class="token operator">-</span><span class="token number">1</span>
        <span class="token function">ShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">SubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">MixColumns</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>round<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>round<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
    <span class="token keyword">end</span>

    <span class="token function">ShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">SubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>Nr<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    out <span class="token operator">=</span> state
<span class="token keyword">end</span>

<span class="token function">InvCipher</span><span class="token punctuation">(</span>byte in<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> byte out<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nb<span class="token punctuation">]</span><span class="token punctuation">,</span> word w<span class="token punctuation">[</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr_1<span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
begin

    byte stae<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> Nb<span class="token punctuation">]</span>
    state <span class="token operator">=</span> in

    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>Nr<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    <span class="token keyword">for</span> round <span class="token operator">=</span> Nr<span class="token operator">-</span><span class="token number">1</span> step <span class="token operator">-</span><span class="token number">1</span> downto <span class="token number">1</span>
        <span class="token function">InvSubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">InvShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">InvMixColumns</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
        <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span>round<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>round<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
    <span class="token keyword">end</span>

    <span class="token function">InvSubBytes</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">InvShiftRows</span><span class="token punctuation">(</span>state<span class="token punctuation">)</span>
    <span class="token function">AddRoundKey</span><span class="token punctuation">(</span>state<span class="token punctuation">,</span> w<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> Nb<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

    out <span class="token operator">=</span> state
<span class="token keyword">end</span>

<span class="token operator">/</span><span class="token operator">/</span> &#x89E3;&#x5BC6;&#x5BC6;&#x94A5;&#x6269;&#x5C55;&#x9700;&#x8981;&#x589E;&#x52A0;&#x5982;&#x4E0B;&#x6B65;&#x9AA4;
<span class="token keyword">for</span> <span class="token number">i</span> <span class="token operator">=</span> <span class="token number">0</span> step <span class="token number">1</span> <span class="token function">to</span> <span class="token punctuation">(</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>
    dw<span class="token punctuation">[</span><span class="token number">i</span><span class="token punctuation">]</span> <span class="token operator">=</span> w<span class="token punctuation">[</span><span class="token number">i</span><span class="token punctuation">]</span>
<span class="token keyword">end</span>
<span class="token operator">/</span><span class="token operator">/</span> &#x589E;&#x52A0;&#x7684;&#x8FD0;&#x7B97;
<span class="token keyword">for</span> round<span class="token operator">=</span><span class="token number">1</span> step <span class="token number">1</span> to Nr<span class="token operator">-</span><span class="token number">1</span>
    <span class="token function">InvMixColumns</span><span class="token punctuation">(</span>dw<span class="token punctuation">[</span>round<span class="token operator">*</span>Nb<span class="token punctuation">,</span> <span class="token punctuation">(</span>round<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span>Nb<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token keyword">end</span> <span class="token keyword">for</span>
</pre><h2 class="mume-header" id="subbytes%E5%8F%98%E6%8D%A2toc"><a href="#toc">SubBytes&#x53D8;&#x6362;</a></h2>

<p>&#x8BB0;&#x5F85;&#x66FF;&#x6362;&#x5B57;&#x8282;&#x4E3A;<code>0xmn</code>, &#x90A3;&#x4E48;&#x66FF;&#x6362;&#x540E;&#x7684;&#x5B57;&#x8282;&#x4E3A;<code>sbox[16 * 0xm + 0xn]</code>, &#x5BF9;&#x5E94;&#x7684;&#x9006;&#x53D8;&#x6362;&#x4E3A;<code>isbox[16 * 0xm + 0xn]</code>;</p>
<p>&#x5047;&#x8BBE;<code>0xab</code>&#x5BF9;&#x5E94;&#x7684;&#x591A;&#x9879;&#x5F0F;&#x4E3A;<span class="mathjax-exps">$f(x)$</span>, sbox&#x7684;&#x8BA1;&#x7B97;&#x6B65;&#x9AA4;&#x5982;&#x4E0B;:</p>
<ol>
<li>&#x6C42;<span class="mathjax-exps">$f(x)$</span>&#x7684;&#x5728;&#x6709;&#x9650;&#x57DF;<span class="mathjax-exps">$GF(2^8)$</span>&#x4E2D;&#x7684;&#x9006;: <span class="mathjax-exps">$f(x)*g(x)=1 \mod(x^8+x^4+x^3+x+1)$</span>;</li>
<li>&#x8BB0;<span class="mathjax-exps">$n(x)$</span>&#x5BF9;&#x5E94;&#x7684;&#x5B57;&#x8282;&#x4E3A;<span class="mathjax-exps">$b_0b_1 \cdots b_7$</span>, &#x6309;&#x7167;&#x5982;&#x4E0B;&#x516C;&#x5F0F;&#x4F9D;&#x6B21;&#x6C42;<span class="mathjax-exps">$[0,255]$</span>&#x5728;<span class="mathjax-exps">$GF(2)$</span>&#x4E0A;&#x7684;&#x653E;&#x5C04;&#x53D8;&#x6362;&#x503C;;</li>
</ol>
<p></p><div class="mathjax-exps">$$b_{i}^{&apos;} = b_{i} \oplus b_{(i+4)mod8} \oplus b_{(i+5)mod8} \oplus b_{(i+6)mod8} \oplus b_{(i+7)mod8} \oplus c_{i}; \quad c=0x63$$</div><p></p>
<h2 class="mume-header" id="shiftrows%E5%8F%98%E6%8D%A2toc"><a href="#toc">ShiftRows&#x53D8;&#x6362;</a></h2>

<p>&#x8BB0;state&#x77E9;&#x9635;&#x4E2D;&#x5F85;&#x66FF;&#x6362;&#x5143;&#x7D20;&#x4E3A;<span class="mathjax-exps">$s_{r,c}$</span>, &#x66FF;&#x6362;&#x540E;&#x7684;&#x5143;&#x7D20;&#x4E3A;<span class="mathjax-exps">$s_{r,c}^{&apos;}$</span>. &#x5176;&#x4E2D;, <span class="mathjax-exps">$r,c$</span>&#x8868;&#x793A;&#x5176;&#x5728;&#x77E9;&#x9635;&#x4E2D;&#x7684;&#x884C;&#x548C;&#x5217;.<br>
&#x90A3;&#x4E48;, &#x66FF;&#x6362;&#x524D;&#x540E;&#x7684;&#x5143;&#x7D20;&#x5173;&#x7CFB;&#x4E3A;:</p>
<p></p><div class="mathjax-exps">$$s_{r,c}^{&apos;} = s_{r, (c+(r \% N_b)) \% N_b}$$</div><p></p>
<p>&#x4E0A;&#x5F0F;&#x5BF9;&#x5E94;&#x7684;&#x9006;&#x53D8;&#x6362;&#x4E3A;:</p>
<p></p><div class="mathjax-exps">$$s_{r,c} = s_{r, (c+(N_b - r)) \% N_b}^{&apos;}$$</div><p></p>
<h2 class="mume-header" id="mixcolumns%E5%8F%98%E6%8D%A2toc"><a href="#toc">MixColumns&#x53D8;&#x6362;</a></h2>

<p>AES&#x4F7F;&#x7528;<span class="mathjax-exps">$a(x)$</span>&#x5BF9;&#x5217;&#x8FDB;&#x884C;&#x53D8;&#x6362;, <span class="mathjax-exps">$a(x)$</span>&#x5B9A;&#x4E49;&#x5982;&#x4E0B;:</p>
<p></p><div class="mathjax-exps">$$a(x) = \{03\}x^3 + \{01\}x^2 + \{01\}x + \{02\} \\ a^{-1}(x) = \{0b\}x^3 + \{0d\}x^2 + \{09\}x + \{0e\}$$</div><p></p>
<p>&#x5219;, MixColumns&#x5BF9;state&#x53D8;&#x6362;&#x524D;&#x540E;&#x7684;&#x5173;&#x7CFB;&#x5982;&#x4E0B;:</p>
<p></p><div class="mathjax-exps">$$\begin{aligned} &amp; s^{&apos;}(x) = a(x) \otimes s(x) \\ &amp; \left[ \begin{matrix} s^{&apos;}_{0,c} \\ s^{&apos;}_{1,c} \\ s^{&apos;}_{2,c} \\ s^{&apos;}_{3,c} \end{matrix} \right] = \left[ \begin{matrix} 02 &amp; 03 &amp; 01 &amp; 01 \\ 01 &amp; 02 &amp; 03 &amp; 01 \\ 01 &amp; 01 &amp; 02 &amp; 03 \\ 03 &amp; 01 &amp; 01 &amp; 02 \end{matrix} \right] \left[ \begin{matrix} s_{0,c} \\ s_{1,c} \\ s_{2,c} \\ s_{3,c} \end{matrix} \right] \end{aligned}$$</div><p></p>
<p>&#x5BF9;&#x5E94;&#x7684;&#x9006;&#x53D8;&#x6362;&#x4E3A;:</p>
<p></p><div class="mathjax-exps">$$\begin{aligned} &amp; s^{&apos;}(x) = a^{-1}(x) \otimes s(x) \\ &amp; \left[ \begin{matrix} s^{&apos;}_{0,c} \\ s^{&apos;}_{1,c} \\ s^{&apos;}_{2,c} \\ s^{&apos;}_{3,c} \end{matrix} \right] = \left[ \begin{matrix} 0e &amp; 0b &amp; 0d &amp; 09 \\ 09 &amp; 0e &amp; 0b &amp; 0d \\ 0d &amp; 09 &amp; 0e &amp; 0b \\ 0b &amp; 0d &amp; 09 &amp; 0e \end{matrix} \right] \left[ \begin{matrix} s_{0,c} \\ s_{1,c} \\ s_{2,c} \\ s_{3,c} \end{matrix} \right] \end{aligned}$$</div><p></p>
<h2 class="mume-header" id="addroundkey%E5%8F%98%E6%8D%A2toc"><a href="#toc">AddRoundKey&#x53D8;&#x6362;</a></h2>

<p></p><div class="mathjax-exps">$$\left[ \begin{matrix} s^{&apos;}_{0,c} &amp; s^{&apos;}_{1,c} &amp; s^{&apos;}_{2,c} &amp; s^{&apos;}_{3,c} \end{matrix} \right] = \left[ \begin{matrix} s_{0,c} &amp; s_{1,c} &amp; s_{2,c} &amp; s_{3,c} \end{matrix} \right] \oplus  \left[ \begin{matrix} w_{round*N_b+0} &amp; w_{round*N_b+1} &amp; w_{round*N_b+2} &amp; w_{round*N_b+3} \end{matrix} \right]$$</div><p></p>
<p>&#x5F02;&#x6216;&#x8FD0;&#x7B97;&#x662F;&#x53EF;&#x9006;&#x7684;, &#x5BF9;&#x5E94;&#x7684;&#x9006;&#x53D8;&#x6362;&#x516C;&#x5F0F;&#x4E0D;&#x53D8;;</p>
<h2 class="mume-header" id="roundkey%E8%AE%A1%E7%AE%97toc"><a href="#toc">RoundKey&#x8BA1;&#x7B97;</a></h2>

<p>RoundKey&#x8BA1;&#x7B97;&#x7B97;&#x6CD5;&#x6D41;&#x7A0B;&#x5982;&#x4E0B;:</p>
<pre data-role="codeBlock" data-info="Matlab" class="language-matlab"><span class="token function">RoundKey</span><span class="token punctuation">(</span>byte key<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span>Nk<span class="token punctuation">]</span><span class="token punctuation">,</span> word w<span class="token punctuation">[</span>Nb<span class="token operator">*</span><span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">,</span> Nk<span class="token punctuation">)</span>
begin

word temp
<span class="token number">i</span> <span class="token operator">=</span> <span class="token number">0</span>

<span class="token keyword">while</span> <span class="token number">i</span> <span class="token operator">&lt;</span> Nk
    w<span class="token punctuation">[</span><span class="token number">i</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token function">word</span><span class="token punctuation">(</span>key<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span><span class="token number">i</span><span class="token punctuation">]</span><span class="token punctuation">,</span> key<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span><span class="token number">i</span><span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span> key<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span><span class="token number">i</span><span class="token operator">+</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span> key<span class="token punctuation">[</span><span class="token number">4</span><span class="token operator">*</span><span class="token number">i</span><span class="token operator">+</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
    <span class="token number">i</span> <span class="token operator">+</span><span class="token operator">=</span> <span class="token number">1</span>
<span class="token keyword">end</span>

<span class="token number">i</span> <span class="token operator">=</span> Nk

<span class="token keyword">while</span> <span class="token number">i</span> <span class="token operator">&lt;</span> Nb <span class="token operator">*</span> <span class="token punctuation">(</span>Nr<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span>
    temp <span class="token operator">=</span> w<span class="token punctuation">[</span><span class="token number">i</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">]</span>
    <span class="token keyword">if</span> <span class="token number">i</span> <span class="token comment">% Nk == 0</span>
        temp <span class="token operator">=</span> <span class="token function">SubWord</span><span class="token punctuation">(</span><span class="token function">RotWord</span><span class="token punctuation">(</span>temp<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">^</span> Rcon<span class="token punctuation">[</span><span class="token number">i</span><span class="token operator">/</span>Nk<span class="token punctuation">]</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> Nk <span class="token operator">&gt;</span> <span class="token number">6</span> <span class="token operator">&amp;&amp;</span> <span class="token number">i</span> <span class="token comment">% Nk == 4</span>
        temp <span class="token operator">=</span> <span class="token function">SubWord</span><span class="token punctuation">(</span>temp<span class="token punctuation">)</span>
    <span class="token keyword">end</span>
    w<span class="token punctuation">[</span><span class="token number">i</span><span class="token punctuation">]</span> <span class="token operator">=</span> w<span class="token punctuation">[</span><span class="token number">i</span><span class="token operator">-</span>Nk<span class="token punctuation">]</span> <span class="token operator">^</span> temp
    <span class="token number">i</span> <span class="token operator">=</span> <span class="token number">i</span> <span class="token operator">+</span> <span class="token number">1</span>
<span class="token keyword">end</span>

<span class="token keyword">end</span>
</pre><ul>
<li>RotWord: &#x5C06;<span class="mathjax-exps">$[a_0,a_1,a_2,a_3]$</span>&#x7FFB;&#x8F6C;&#x4E3A;<span class="mathjax-exps">$[a_1,a_2,a_3,a_0]$</span>;</li>
<li>SubWord: &#x901A;&#x8FC7;sbox&#x5B8C;&#x6210;&#x975E;&#x7EBF;&#x6027;&#x53D8;&#x6362;;</li>
<li>Rcon: [<span class="mathjax-exps">$x^{i-1} mod(x^8+x^4+x^3+x+1)$</span>, {00}, {00}, {00}], i = [1-10];</li>
</ul>
<h2 class="mume-header" id="%E9%99%84%E5%BD%95toc"><a href="#toc">&#x9644;&#x5F55;</a></h2>

<h3 class="mume-header" id="%E9%9D%9E%E7%BA%BF%E6%80%A7%E5%AD%97%E8%8A%82%E6%9B%BF%E6%8D%A2%E8%A1%A8toc"><a href="#toc">&#x975E;&#x7EBF;&#x6027;&#x5B57;&#x8282;&#x66FF;&#x6362;&#x8868;</a></h3>

<pre data-role="codeBlock" data-info="rust" class="language-rust"><span class="token keyword">let</span> sbox<span class="token punctuation">[</span>u8<span class="token punctuation">;</span> <span class="token number">256</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
    <span class="token number">0x63</span><span class="token punctuation">,</span> <span class="token number">0x7c</span><span class="token punctuation">,</span> <span class="token number">0x77</span><span class="token punctuation">,</span> <span class="token number">0x7b</span><span class="token punctuation">,</span> <span class="token number">0xf2</span><span class="token punctuation">,</span> <span class="token number">0x6b</span><span class="token punctuation">,</span> <span class="token number">0x6f</span><span class="token punctuation">,</span> <span class="token number">0xc5</span><span class="token punctuation">,</span> <span class="token number">0x30</span><span class="token punctuation">,</span> <span class="token number">0x01</span><span class="token punctuation">,</span> <span class="token number">0x67</span><span class="token punctuation">,</span> <span class="token number">0x2b</span><span class="token punctuation">,</span> <span class="token number">0xfe</span><span class="token punctuation">,</span> <span class="token number">0xd7</span><span class="token punctuation">,</span> <span class="token number">0xab</span><span class="token punctuation">,</span> <span class="token number">0x76</span><span class="token punctuation">,</span>
    <span class="token number">0xca</span><span class="token punctuation">,</span> <span class="token number">0x82</span><span class="token punctuation">,</span> <span class="token number">0xc9</span><span class="token punctuation">,</span> <span class="token number">0x7d</span><span class="token punctuation">,</span> <span class="token number">0xfa</span><span class="token punctuation">,</span> <span class="token number">0x59</span><span class="token punctuation">,</span> <span class="token number">0x47</span><span class="token punctuation">,</span> <span class="token number">0xf0</span><span class="token punctuation">,</span> <span class="token number">0xad</span><span class="token punctuation">,</span> <span class="token number">0xd4</span><span class="token punctuation">,</span> <span class="token number">0xa2</span><span class="token punctuation">,</span> <span class="token number">0xaf</span><span class="token punctuation">,</span> <span class="token number">0x9c</span><span class="token punctuation">,</span> <span class="token number">0xa4</span><span class="token punctuation">,</span> <span class="token number">0x72</span><span class="token punctuation">,</span> <span class="token number">0xc0</span><span class="token punctuation">,</span>
    <span class="token number">0xb7</span><span class="token punctuation">,</span> <span class="token number">0xfd</span><span class="token punctuation">,</span> <span class="token number">0x93</span><span class="token punctuation">,</span> <span class="token number">0x26</span><span class="token punctuation">,</span> <span class="token number">0x36</span><span class="token punctuation">,</span> <span class="token number">0x3f</span><span class="token punctuation">,</span> <span class="token number">0xf7</span><span class="token punctuation">,</span> <span class="token number">0xcc</span><span class="token punctuation">,</span> <span class="token number">0x34</span><span class="token punctuation">,</span> <span class="token number">0xa5</span><span class="token punctuation">,</span> <span class="token number">0xe5</span><span class="token punctuation">,</span> <span class="token number">0xf1</span><span class="token punctuation">,</span> <span class="token number">0x71</span><span class="token punctuation">,</span> <span class="token number">0xd8</span><span class="token punctuation">,</span> <span class="token number">0x31</span><span class="token punctuation">,</span> <span class="token number">0x15</span><span class="token punctuation">,</span>
    <span class="token number">0x04</span><span class="token punctuation">,</span> <span class="token number">0xc7</span><span class="token punctuation">,</span> <span class="token number">0x23</span><span class="token punctuation">,</span> <span class="token number">0xc3</span><span class="token punctuation">,</span> <span class="token number">0x18</span><span class="token punctuation">,</span> <span class="token number">0x96</span><span class="token punctuation">,</span> <span class="token number">0x05</span><span class="token punctuation">,</span> <span class="token number">0x9a</span><span class="token punctuation">,</span> <span class="token number">0x07</span><span class="token punctuation">,</span> <span class="token number">0x12</span><span class="token punctuation">,</span> <span class="token number">0x80</span><span class="token punctuation">,</span> <span class="token number">0xe2</span><span class="token punctuation">,</span> <span class="token number">0xeb</span><span class="token punctuation">,</span> <span class="token number">0x27</span><span class="token punctuation">,</span> <span class="token number">0xb2</span><span class="token punctuation">,</span> <span class="token number">0x75</span><span class="token punctuation">,</span>
    <span class="token number">0x09</span><span class="token punctuation">,</span> <span class="token number">0x83</span><span class="token punctuation">,</span> <span class="token number">0x2c</span><span class="token punctuation">,</span> <span class="token number">0x1a</span><span class="token punctuation">,</span> <span class="token number">0x1b</span><span class="token punctuation">,</span> <span class="token number">0x6e</span><span class="token punctuation">,</span> <span class="token number">0x5a</span><span class="token punctuation">,</span> <span class="token number">0xa0</span><span class="token punctuation">,</span> <span class="token number">0x52</span><span class="token punctuation">,</span> <span class="token number">0x3b</span><span class="token punctuation">,</span> <span class="token number">0xd6</span><span class="token punctuation">,</span> <span class="token number">0xb3</span><span class="token punctuation">,</span> <span class="token number">0x29</span><span class="token punctuation">,</span> <span class="token number">0xe3</span><span class="token punctuation">,</span> <span class="token number">0x2f</span><span class="token punctuation">,</span> <span class="token number">0x84</span><span class="token punctuation">,</span>
    <span class="token number">0x53</span><span class="token punctuation">,</span> <span class="token number">0xd1</span><span class="token punctuation">,</span> <span class="token number">0x00</span><span class="token punctuation">,</span> <span class="token number">0xed</span><span class="token punctuation">,</span> <span class="token number">0x20</span><span class="token punctuation">,</span> <span class="token number">0xfc</span><span class="token punctuation">,</span> <span class="token number">0xb1</span><span class="token punctuation">,</span> <span class="token number">0x5b</span><span class="token punctuation">,</span> <span class="token number">0x6a</span><span class="token punctuation">,</span> <span class="token number">0xcb</span><span class="token punctuation">,</span> <span class="token number">0xbe</span><span class="token punctuation">,</span> <span class="token number">0x39</span><span class="token punctuation">,</span> <span class="token number">0x4a</span><span class="token punctuation">,</span> <span class="token number">0x4c</span><span class="token punctuation">,</span> <span class="token number">0x58</span><span class="token punctuation">,</span> <span class="token number">0xcf</span><span class="token punctuation">,</span>
    <span class="token number">0xd0</span><span class="token punctuation">,</span> <span class="token number">0xef</span><span class="token punctuation">,</span> <span class="token number">0xaa</span><span class="token punctuation">,</span> <span class="token number">0xfb</span><span class="token punctuation">,</span> <span class="token number">0x43</span><span class="token punctuation">,</span> <span class="token number">0x4d</span><span class="token punctuation">,</span> <span class="token number">0x33</span><span class="token punctuation">,</span> <span class="token number">0x85</span><span class="token punctuation">,</span> <span class="token number">0x45</span><span class="token punctuation">,</span> <span class="token number">0xf9</span><span class="token punctuation">,</span> <span class="token number">0x02</span><span class="token punctuation">,</span> <span class="token number">0x7f</span><span class="token punctuation">,</span> <span class="token number">0x50</span><span class="token punctuation">,</span> <span class="token number">0x3c</span><span class="token punctuation">,</span> <span class="token number">0x9f</span><span class="token punctuation">,</span> <span class="token number">0xa8</span><span class="token punctuation">,</span>
    <span class="token number">0x51</span><span class="token punctuation">,</span> <span class="token number">0xa3</span><span class="token punctuation">,</span> <span class="token number">0x40</span><span class="token punctuation">,</span> <span class="token number">0x8f</span><span class="token punctuation">,</span> <span class="token number">0x92</span><span class="token punctuation">,</span> <span class="token number">0x9d</span><span class="token punctuation">,</span> <span class="token number">0x38</span><span class="token punctuation">,</span> <span class="token number">0xf5</span><span class="token punctuation">,</span> <span class="token number">0xbc</span><span class="token punctuation">,</span> <span class="token number">0xb6</span><span class="token punctuation">,</span> <span class="token number">0xda</span><span class="token punctuation">,</span> <span class="token number">0x21</span><span class="token punctuation">,</span> <span class="token number">0x10</span><span class="token punctuation">,</span> <span class="token number">0xff</span><span class="token punctuation">,</span> <span class="token number">0xf3</span><span class="token punctuation">,</span> <span class="token number">0xd2</span><span class="token punctuation">,</span>
    <span class="token number">0xcd</span><span class="token punctuation">,</span> <span class="token number">0x0c</span><span class="token punctuation">,</span> <span class="token number">0x13</span><span class="token punctuation">,</span> <span class="token number">0xec</span><span class="token punctuation">,</span> <span class="token number">0x5f</span><span class="token punctuation">,</span> <span class="token number">0x97</span><span class="token punctuation">,</span> <span class="token number">0x44</span><span class="token punctuation">,</span> <span class="token number">0x17</span><span class="token punctuation">,</span> <span class="token number">0xc4</span><span class="token punctuation">,</span> <span class="token number">0xa7</span><span class="token punctuation">,</span> <span class="token number">0x7e</span><span class="token punctuation">,</span> <span class="token number">0x3d</span><span class="token punctuation">,</span> <span class="token number">0x64</span><span class="token punctuation">,</span> <span class="token number">0x5d</span><span class="token punctuation">,</span> <span class="token number">0x19</span><span class="token punctuation">,</span> <span class="token number">0x73</span><span class="token punctuation">,</span>
    <span class="token number">0x60</span><span class="token punctuation">,</span> <span class="token number">0x81</span><span class="token punctuation">,</span> <span class="token number">0x4f</span><span class="token punctuation">,</span> <span class="token number">0xdc</span><span class="token punctuation">,</span> <span class="token number">0x22</span><span class="token punctuation">,</span> <span class="token number">0x2a</span><span class="token punctuation">,</span> <span class="token number">0x90</span><span class="token punctuation">,</span> <span class="token number">0x88</span><span class="token punctuation">,</span> <span class="token number">0x46</span><span class="token punctuation">,</span> <span class="token number">0xee</span><span class="token punctuation">,</span> <span class="token number">0xb8</span><span class="token punctuation">,</span> <span class="token number">0x14</span><span class="token punctuation">,</span> <span class="token number">0xde</span><span class="token punctuation">,</span> <span class="token number">0x5e</span><span class="token punctuation">,</span> <span class="token number">0x0b</span><span class="token punctuation">,</span> <span class="token number">0xdb</span><span class="token punctuation">,</span>
    <span class="token number">0xe0</span><span class="token punctuation">,</span> <span class="token number">0x32</span><span class="token punctuation">,</span> <span class="token number">0x3a</span><span class="token punctuation">,</span> <span class="token number">0x0a</span><span class="token punctuation">,</span> <span class="token number">0x49</span><span class="token punctuation">,</span> <span class="token number">0x06</span><span class="token punctuation">,</span> <span class="token number">0x24</span><span class="token punctuation">,</span> <span class="token number">0x5c</span><span class="token punctuation">,</span> <span class="token number">0xc2</span><span class="token punctuation">,</span> <span class="token number">0xd3</span><span class="token punctuation">,</span> <span class="token number">0xac</span><span class="token punctuation">,</span> <span class="token number">0x62</span><span class="token punctuation">,</span> <span class="token number">0x91</span><span class="token punctuation">,</span> <span class="token number">0x95</span><span class="token punctuation">,</span> <span class="token number">0xe4</span><span class="token punctuation">,</span> <span class="token number">0x79</span><span class="token punctuation">,</span>
    <span class="token number">0xe7</span><span class="token punctuation">,</span> <span class="token number">0xc8</span><span class="token punctuation">,</span> <span class="token number">0x37</span><span class="token punctuation">,</span> <span class="token number">0x6d</span><span class="token punctuation">,</span> <span class="token number">0x8d</span><span class="token punctuation">,</span> <span class="token number">0xd5</span><span class="token punctuation">,</span> <span class="token number">0x4e</span><span class="token punctuation">,</span> <span class="token number">0xa9</span><span class="token punctuation">,</span> <span class="token number">0x6c</span><span class="token punctuation">,</span> <span class="token number">0x56</span><span class="token punctuation">,</span> <span class="token number">0xf4</span><span class="token punctuation">,</span> <span class="token number">0xea</span><span class="token punctuation">,</span> <span class="token number">0x65</span><span class="token punctuation">,</span> <span class="token number">0x7a</span><span class="token punctuation">,</span> <span class="token number">0xae</span><span class="token punctuation">,</span> <span class="token number">0x08</span><span class="token punctuation">,</span>
    <span class="token number">0xba</span><span class="token punctuation">,</span> <span class="token number">0x78</span><span class="token punctuation">,</span> <span class="token number">0x25</span><span class="token punctuation">,</span> <span class="token number">0x2e</span><span class="token punctuation">,</span> <span class="token number">0x1c</span><span class="token punctuation">,</span> <span class="token number">0xa6</span><span class="token punctuation">,</span> <span class="token number">0xb4</span><span class="token punctuation">,</span> <span class="token number">0xc6</span><span class="token punctuation">,</span> <span class="token number">0xe8</span><span class="token punctuation">,</span> <span class="token number">0xdd</span><span class="token punctuation">,</span> <span class="token number">0x74</span><span class="token punctuation">,</span> <span class="token number">0x1f</span><span class="token punctuation">,</span> <span class="token number">0x4b</span><span class="token punctuation">,</span> <span class="token number">0xbd</span><span class="token punctuation">,</span> <span class="token number">0x8b</span><span class="token punctuation">,</span> <span class="token number">0x8a</span><span class="token punctuation">,</span>
    <span class="token number">0x70</span><span class="token punctuation">,</span> <span class="token number">0x3e</span><span class="token punctuation">,</span> <span class="token number">0xb5</span><span class="token punctuation">,</span> <span class="token number">0x66</span><span class="token punctuation">,</span> <span class="token number">0x48</span><span class="token punctuation">,</span> <span class="token number">0x03</span><span class="token punctuation">,</span> <span class="token number">0xf6</span><span class="token punctuation">,</span> <span class="token number">0x0e</span><span class="token punctuation">,</span> <span class="token number">0x61</span><span class="token punctuation">,</span> <span class="token number">0x35</span><span class="token punctuation">,</span> <span class="token number">0x57</span><span class="token punctuation">,</span> <span class="token number">0xb9</span><span class="token punctuation">,</span> <span class="token number">0x86</span><span class="token punctuation">,</span> <span class="token number">0xc1</span><span class="token punctuation">,</span> <span class="token number">0x1d</span><span class="token punctuation">,</span> <span class="token number">0x9e</span><span class="token punctuation">,</span>
    <span class="token number">0xe1</span><span class="token punctuation">,</span> <span class="token number">0xf8</span><span class="token punctuation">,</span> <span class="token number">0x98</span><span class="token punctuation">,</span> <span class="token number">0x11</span><span class="token punctuation">,</span> <span class="token number">0x69</span><span class="token punctuation">,</span> <span class="token number">0xd9</span><span class="token punctuation">,</span> <span class="token number">0x8e</span><span class="token punctuation">,</span> <span class="token number">0x94</span><span class="token punctuation">,</span> <span class="token number">0x9b</span><span class="token punctuation">,</span> <span class="token number">0x1e</span><span class="token punctuation">,</span> <span class="token number">0x87</span><span class="token punctuation">,</span> <span class="token number">0xe9</span><span class="token punctuation">,</span> <span class="token number">0xce</span><span class="token punctuation">,</span> <span class="token number">0x55</span><span class="token punctuation">,</span> <span class="token number">0x28</span><span class="token punctuation">,</span> <span class="token number">0xdf</span><span class="token punctuation">,</span>
    <span class="token number">0x8c</span><span class="token punctuation">,</span> <span class="token number">0xa1</span><span class="token punctuation">,</span> <span class="token number">0x89</span><span class="token punctuation">,</span> <span class="token number">0x0d</span><span class="token punctuation">,</span> <span class="token number">0xbf</span><span class="token punctuation">,</span> <span class="token number">0xe6</span><span class="token punctuation">,</span> <span class="token number">0x42</span><span class="token punctuation">,</span> <span class="token number">0x68</span><span class="token punctuation">,</span> <span class="token number">0x41</span><span class="token punctuation">,</span> <span class="token number">0x99</span><span class="token punctuation">,</span> <span class="token number">0x2d</span><span class="token punctuation">,</span> <span class="token number">0x0f</span><span class="token punctuation">,</span> <span class="token number">0xb0</span><span class="token punctuation">,</span> <span class="token number">0x54</span><span class="token punctuation">,</span> <span class="token number">0xbb</span><span class="token punctuation">,</span> <span class="token number">0x16</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> isbox<span class="token punctuation">[</span>u8<span class="token punctuation">;</span> <span class="token number">256</span><span class="token punctuation">]</span><span class="token operator">=</span> <span class="token punctuation">[</span>
    <span class="token number">0x52</span><span class="token punctuation">,</span> <span class="token number">0x09</span><span class="token punctuation">,</span> <span class="token number">0x6a</span><span class="token punctuation">,</span> <span class="token number">0xd5</span><span class="token punctuation">,</span> <span class="token number">0x30</span><span class="token punctuation">,</span> <span class="token number">0x36</span><span class="token punctuation">,</span> <span class="token number">0xa5</span><span class="token punctuation">,</span> <span class="token number">0x38</span><span class="token punctuation">,</span> <span class="token number">0xbf</span><span class="token punctuation">,</span> <span class="token number">0x40</span><span class="token punctuation">,</span> <span class="token number">0xa3</span><span class="token punctuation">,</span> <span class="token number">0x9e</span><span class="token punctuation">,</span> <span class="token number">0x81</span><span class="token punctuation">,</span> <span class="token number">0xf3</span><span class="token punctuation">,</span> <span class="token number">0xd7</span><span class="token punctuation">,</span> <span class="token number">0xfb</span><span class="token punctuation">,</span>
    <span class="token number">0x7c</span><span class="token punctuation">,</span> <span class="token number">0xe3</span><span class="token punctuation">,</span> <span class="token number">0x39</span><span class="token punctuation">,</span> <span class="token number">0x82</span><span class="token punctuation">,</span> <span class="token number">0x9b</span><span class="token punctuation">,</span> <span class="token number">0x2f</span><span class="token punctuation">,</span> <span class="token number">0xff</span><span class="token punctuation">,</span> <span class="token number">0x87</span><span class="token punctuation">,</span> <span class="token number">0x34</span><span class="token punctuation">,</span> <span class="token number">0x8e</span><span class="token punctuation">,</span> <span class="token number">0x43</span><span class="token punctuation">,</span> <span class="token number">0x44</span><span class="token punctuation">,</span> <span class="token number">0xc4</span><span class="token punctuation">,</span> <span class="token number">0xde</span><span class="token punctuation">,</span> <span class="token number">0xe9</span><span class="token punctuation">,</span> <span class="token number">0xcb</span><span class="token punctuation">,</span>
    <span class="token number">0x54</span><span class="token punctuation">,</span> <span class="token number">0x7b</span><span class="token punctuation">,</span> <span class="token number">0x94</span><span class="token punctuation">,</span> <span class="token number">0x32</span><span class="token punctuation">,</span> <span class="token number">0xa6</span><span class="token punctuation">,</span> <span class="token number">0xc2</span><span class="token punctuation">,</span> <span class="token number">0x23</span><span class="token punctuation">,</span> <span class="token number">0x3d</span><span class="token punctuation">,</span> <span class="token number">0xee</span><span class="token punctuation">,</span> <span class="token number">0x4c</span><span class="token punctuation">,</span> <span class="token number">0x95</span><span class="token punctuation">,</span> <span class="token number">0x0b</span><span class="token punctuation">,</span> <span class="token number">0x42</span><span class="token punctuation">,</span> <span class="token number">0xfa</span><span class="token punctuation">,</span> <span class="token number">0xc3</span><span class="token punctuation">,</span> <span class="token number">0x4e</span><span class="token punctuation">,</span>
    <span class="token number">0x08</span><span class="token punctuation">,</span> <span class="token number">0x2e</span><span class="token punctuation">,</span> <span class="token number">0xa1</span><span class="token punctuation">,</span> <span class="token number">0x66</span><span class="token punctuation">,</span> <span class="token number">0x28</span><span class="token punctuation">,</span> <span class="token number">0xd9</span><span class="token punctuation">,</span> <span class="token number">0x24</span><span class="token punctuation">,</span> <span class="token number">0xb2</span><span class="token punctuation">,</span> <span class="token number">0x76</span><span class="token punctuation">,</span> <span class="token number">0x5b</span><span class="token punctuation">,</span> <span class="token number">0xa2</span><span class="token punctuation">,</span> <span class="token number">0x49</span><span class="token punctuation">,</span> <span class="token number">0x6d</span><span class="token punctuation">,</span> <span class="token number">0x8b</span><span class="token punctuation">,</span> <span class="token number">0xd1</span><span class="token punctuation">,</span> <span class="token number">0x25</span><span class="token punctuation">,</span>
    <span class="token number">0x72</span><span class="token punctuation">,</span> <span class="token number">0xf8</span><span class="token punctuation">,</span> <span class="token number">0xf6</span><span class="token punctuation">,</span> <span class="token number">0x64</span><span class="token punctuation">,</span> <span class="token number">0x86</span><span class="token punctuation">,</span> <span class="token number">0x68</span><span class="token punctuation">,</span> <span class="token number">0x98</span><span class="token punctuation">,</span> <span class="token number">0x16</span><span class="token punctuation">,</span> <span class="token number">0xd4</span><span class="token punctuation">,</span> <span class="token number">0xa4</span><span class="token punctuation">,</span> <span class="token number">0x5c</span><span class="token punctuation">,</span> <span class="token number">0xcc</span><span class="token punctuation">,</span> <span class="token number">0x5d</span><span class="token punctuation">,</span> <span class="token number">0x65</span><span class="token punctuation">,</span> <span class="token number">0xb6</span><span class="token punctuation">,</span> <span class="token number">0x92</span><span class="token punctuation">,</span>
    <span class="token number">0x6c</span><span class="token punctuation">,</span> <span class="token number">0x70</span><span class="token punctuation">,</span> <span class="token number">0x48</span><span class="token punctuation">,</span> <span class="token number">0x50</span><span class="token punctuation">,</span> <span class="token number">0xfd</span><span class="token punctuation">,</span> <span class="token number">0xed</span><span class="token punctuation">,</span> <span class="token number">0xb9</span><span class="token punctuation">,</span> <span class="token number">0xda</span><span class="token punctuation">,</span> <span class="token number">0x5e</span><span class="token punctuation">,</span> <span class="token number">0x15</span><span class="token punctuation">,</span> <span class="token number">0x46</span><span class="token punctuation">,</span> <span class="token number">0x57</span><span class="token punctuation">,</span> <span class="token number">0xa7</span><span class="token punctuation">,</span> <span class="token number">0x8d</span><span class="token punctuation">,</span> <span class="token number">0x9d</span><span class="token punctuation">,</span> <span class="token number">0x84</span><span class="token punctuation">,</span>
    <span class="token number">0x90</span><span class="token punctuation">,</span> <span class="token number">0xd8</span><span class="token punctuation">,</span> <span class="token number">0xab</span><span class="token punctuation">,</span> <span class="token number">0x00</span><span class="token punctuation">,</span> <span class="token number">0x8c</span><span class="token punctuation">,</span> <span class="token number">0xbc</span><span class="token punctuation">,</span> <span class="token number">0xd3</span><span class="token punctuation">,</span> <span class="token number">0x0a</span><span class="token punctuation">,</span> <span class="token number">0xf7</span><span class="token punctuation">,</span> <span class="token number">0xe4</span><span class="token punctuation">,</span> <span class="token number">0x58</span><span class="token punctuation">,</span> <span class="token number">0x05</span><span class="token punctuation">,</span> <span class="token number">0xb8</span><span class="token punctuation">,</span> <span class="token number">0xb3</span><span class="token punctuation">,</span> <span class="token number">0x45</span><span class="token punctuation">,</span> <span class="token number">0x06</span><span class="token punctuation">,</span>
    <span class="token number">0xd0</span><span class="token punctuation">,</span> <span class="token number">0x2c</span><span class="token punctuation">,</span> <span class="token number">0x1e</span><span class="token punctuation">,</span> <span class="token number">0x8f</span><span class="token punctuation">,</span> <span class="token number">0xca</span><span class="token punctuation">,</span> <span class="token number">0x3f</span><span class="token punctuation">,</span> <span class="token number">0x0f</span><span class="token punctuation">,</span> <span class="token number">0x02</span><span class="token punctuation">,</span> <span class="token number">0xc1</span><span class="token punctuation">,</span> <span class="token number">0xaf</span><span class="token punctuation">,</span> <span class="token number">0xbd</span><span class="token punctuation">,</span> <span class="token number">0x03</span><span class="token punctuation">,</span> <span class="token number">0x01</span><span class="token punctuation">,</span> <span class="token number">0x13</span><span class="token punctuation">,</span> <span class="token number">0x8a</span><span class="token punctuation">,</span> <span class="token number">0x6b</span><span class="token punctuation">,</span>
    <span class="token number">0x3a</span><span class="token punctuation">,</span> <span class="token number">0x91</span><span class="token punctuation">,</span> <span class="token number">0x11</span><span class="token punctuation">,</span> <span class="token number">0x41</span><span class="token punctuation">,</span> <span class="token number">0x4f</span><span class="token punctuation">,</span> <span class="token number">0x67</span><span class="token punctuation">,</span> <span class="token number">0xdc</span><span class="token punctuation">,</span> <span class="token number">0xea</span><span class="token punctuation">,</span> <span class="token number">0x97</span><span class="token punctuation">,</span> <span class="token number">0xf2</span><span class="token punctuation">,</span> <span class="token number">0xcf</span><span class="token punctuation">,</span> <span class="token number">0xce</span><span class="token punctuation">,</span> <span class="token number">0xf0</span><span class="token punctuation">,</span> <span class="token number">0xb4</span><span class="token punctuation">,</span> <span class="token number">0xe6</span><span class="token punctuation">,</span> <span class="token number">0x73</span><span class="token punctuation">,</span>
    <span class="token number">0x96</span><span class="token punctuation">,</span> <span class="token number">0xac</span><span class="token punctuation">,</span> <span class="token number">0x74</span><span class="token punctuation">,</span> <span class="token number">0x22</span><span class="token punctuation">,</span> <span class="token number">0xe7</span><span class="token punctuation">,</span> <span class="token number">0xad</span><span class="token punctuation">,</span> <span class="token number">0x35</span><span class="token punctuation">,</span> <span class="token number">0x85</span><span class="token punctuation">,</span> <span class="token number">0xe2</span><span class="token punctuation">,</span> <span class="token number">0xf9</span><span class="token punctuation">,</span> <span class="token number">0x37</span><span class="token punctuation">,</span> <span class="token number">0xe8</span><span class="token punctuation">,</span> <span class="token number">0x1c</span><span class="token punctuation">,</span> <span class="token number">0x75</span><span class="token punctuation">,</span> <span class="token number">0xdf</span><span class="token punctuation">,</span> <span class="token number">0x6e</span><span class="token punctuation">,</span>
    <span class="token number">0x47</span><span class="token punctuation">,</span> <span class="token number">0xf1</span><span class="token punctuation">,</span> <span class="token number">0x1a</span><span class="token punctuation">,</span> <span class="token number">0x71</span><span class="token punctuation">,</span> <span class="token number">0x1d</span><span class="token punctuation">,</span> <span class="token number">0x29</span><span class="token punctuation">,</span> <span class="token number">0xc5</span><span class="token punctuation">,</span> <span class="token number">0x89</span><span class="token punctuation">,</span> <span class="token number">0x6f</span><span class="token punctuation">,</span> <span class="token number">0xb7</span><span class="token punctuation">,</span> <span class="token number">0x62</span><span class="token punctuation">,</span> <span class="token number">0x0e</span><span class="token punctuation">,</span> <span class="token number">0xaa</span><span class="token punctuation">,</span> <span class="token number">0x18</span><span class="token punctuation">,</span> <span class="token number">0xbe</span><span class="token punctuation">,</span> <span class="token number">0x1b</span><span class="token punctuation">,</span>
    <span class="token number">0xfc</span><span class="token punctuation">,</span> <span class="token number">0x56</span><span class="token punctuation">,</span> <span class="token number">0x3e</span><span class="token punctuation">,</span> <span class="token number">0x4b</span><span class="token punctuation">,</span> <span class="token number">0xc6</span><span class="token punctuation">,</span> <span class="token number">0xd2</span><span class="token punctuation">,</span> <span class="token number">0x79</span><span class="token punctuation">,</span> <span class="token number">0x20</span><span class="token punctuation">,</span> <span class="token number">0x9a</span><span class="token punctuation">,</span> <span class="token number">0xdb</span><span class="token punctuation">,</span> <span class="token number">0xc0</span><span class="token punctuation">,</span> <span class="token number">0xfe</span><span class="token punctuation">,</span> <span class="token number">0x78</span><span class="token punctuation">,</span> <span class="token number">0xcd</span><span class="token punctuation">,</span> <span class="token number">0x5a</span><span class="token punctuation">,</span> <span class="token number">0xf4</span><span class="token punctuation">,</span>
    <span class="token number">0x1f</span><span class="token punctuation">,</span> <span class="token number">0xdd</span><span class="token punctuation">,</span> <span class="token number">0xa8</span><span class="token punctuation">,</span> <span class="token number">0x33</span><span class="token punctuation">,</span> <span class="token number">0x88</span><span class="token punctuation">,</span> <span class="token number">0x07</span><span class="token punctuation">,</span> <span class="token number">0xc7</span><span class="token punctuation">,</span> <span class="token number">0x31</span><span class="token punctuation">,</span> <span class="token number">0xb1</span><span class="token punctuation">,</span> <span class="token number">0x12</span><span class="token punctuation">,</span> <span class="token number">0x10</span><span class="token punctuation">,</span> <span class="token number">0x59</span><span class="token punctuation">,</span> <span class="token number">0x27</span><span class="token punctuation">,</span> <span class="token number">0x80</span><span class="token punctuation">,</span> <span class="token number">0xec</span><span class="token punctuation">,</span> <span class="token number">0x5f</span><span class="token punctuation">,</span>
    <span class="token number">0x60</span><span class="token punctuation">,</span> <span class="token number">0x51</span><span class="token punctuation">,</span> <span class="token number">0x7f</span><span class="token punctuation">,</span> <span class="token number">0xa9</span><span class="token punctuation">,</span> <span class="token number">0x19</span><span class="token punctuation">,</span> <span class="token number">0xb5</span><span class="token punctuation">,</span> <span class="token number">0x4a</span><span class="token punctuation">,</span> <span class="token number">0x0d</span><span class="token punctuation">,</span> <span class="token number">0x2d</span><span class="token punctuation">,</span> <span class="token number">0xe5</span><span class="token punctuation">,</span> <span class="token number">0x7a</span><span class="token punctuation">,</span> <span class="token number">0x9f</span><span class="token punctuation">,</span> <span class="token number">0x93</span><span class="token punctuation">,</span> <span class="token number">0xc9</span><span class="token punctuation">,</span> <span class="token number">0x9c</span><span class="token punctuation">,</span> <span class="token number">0xef</span><span class="token punctuation">,</span>
    <span class="token number">0xa0</span><span class="token punctuation">,</span> <span class="token number">0xe0</span><span class="token punctuation">,</span> <span class="token number">0x3b</span><span class="token punctuation">,</span> <span class="token number">0x4d</span><span class="token punctuation">,</span> <span class="token number">0xae</span><span class="token punctuation">,</span> <span class="token number">0x2a</span><span class="token punctuation">,</span> <span class="token number">0xf5</span><span class="token punctuation">,</span> <span class="token number">0xb0</span><span class="token punctuation">,</span> <span class="token number">0xc8</span><span class="token punctuation">,</span> <span class="token number">0xeb</span><span class="token punctuation">,</span> <span class="token number">0xbb</span><span class="token punctuation">,</span> <span class="token number">0x3c</span><span class="token punctuation">,</span> <span class="token number">0x83</span><span class="token punctuation">,</span> <span class="token number">0x53</span><span class="token punctuation">,</span> <span class="token number">0x99</span><span class="token punctuation">,</span> <span class="token number">0x61</span><span class="token punctuation">,</span>
    <span class="token number">0x17</span><span class="token punctuation">,</span> <span class="token number">0x2b</span><span class="token punctuation">,</span> <span class="token number">0x04</span><span class="token punctuation">,</span> <span class="token number">0x7e</span><span class="token punctuation">,</span> <span class="token number">0xba</span><span class="token punctuation">,</span> <span class="token number">0x77</span><span class="token punctuation">,</span> <span class="token number">0xd6</span><span class="token punctuation">,</span> <span class="token number">0x26</span><span class="token punctuation">,</span> <span class="token number">0xe1</span><span class="token punctuation">,</span> <span class="token number">0x69</span><span class="token punctuation">,</span> <span class="token number">0x14</span><span class="token punctuation">,</span> <span class="token number">0x63</span><span class="token punctuation">,</span> <span class="token number">0x55</span><span class="token punctuation">,</span> <span class="token number">0x21</span><span class="token punctuation">,</span> <span class="token number">0x0c</span><span class="token punctuation">,</span> <span class="token number">0x7d</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> rcon<span class="token punctuation">[</span>u8<span class="token punctuation">;</span> <span class="token number">10</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
    <span class="token number">0x01000000</span><span class="token punctuation">,</span> <span class="token number">0x02000000</span><span class="token punctuation">,</span> <span class="token number">0x04000000</span><span class="token punctuation">,</span> <span class="token number">0x08000000</span><span class="token punctuation">,</span> <span class="token number">0x10000000</span><span class="token punctuation">,</span> <span class="token number">0x20000000</span><span class="token punctuation">,</span>
    <span class="token number">0x40000000</span><span class="token punctuation">,</span> <span class="token number">0x80000000</span><span class="token punctuation">,</span> <span class="token number">0x1b000000</span><span class="token punctuation">,</span> <span class="token number">0x36000000</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>
</pre><h2 class="mume-header" id="%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99toc"><a href="#toc">&#x53C2;&#x8003;&#x8D44;&#x6599;</a></h2>

<ul>
<li><a href="http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf">FIPS-197 AES</a>;</li>
</ul>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>